package com;

import java.util.ArrayList;


public class GenericExample {

    public static <y> void main(String[] args) {
        String[] arr = {"A","B","C","D","E","F"};
        genDemo(arr);
        Integer[] arrInt = {1,2,3,4,5,6,7};
        genDemo(arrInt);
        ArrayList<y> newInnerList = new ArrayList<y>();
        Integer i = 1;
    }  
    
    
    //用泛型写一个方法，将一数组中的元素反转过来
    public static <y> void genDemo(y arr[]){
        int len = arr.length - 1;
        int start = 0;
        while(true){
            if(start >= len){
                break;
            }
            y temp = arr[start];
            arr[start] = arr[len];
            arr[len] = temp;
            start ++;
            len --;
        }
        for (y t : arr) {
            System.out.println(t);
            //输出结果：FEDCBA7654321
        }
    }
}